package weekMatch.one_347;

public class LeeCode_03 {
    public static void main(String[] args) {
        System.out.println(minimumCost("1100"));
        System.out.println(minimumCost("010101"));
    }
    private static long minimumCost(String s) {
        char[] cs = s.toCharArray();
        int n = cs.length;
        long ans = 0;
        for (int i = 1; i < n; i++) {
            if (cs[i] != cs[i - 1]){
                ans += Math.min(i, n - i);
            }
        }
        return ans;
    }
}
